package javamusic.Servlet.Comentario;

import java.io.IOException;

import javamusic.negocio.GestionComentario;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ServletComentarioInsertar
 */
@WebServlet("/ServletComentarioInsertar")
public class ServletComentarioInsertar extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletComentarioInsertar() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String idcomentario1 = request.getParameter("idcomentario");
		int idcomentario = Integer.parseInt(idcomentario1);
		
		String calificacion = request.getParameter("calificacion");
		
		String descripcion = request.getParameter("descripcion");
		
		String idsala1 = request.getParameter("idsala");
		int idsala = Integer.parseInt(idsala1);
		
		try {
			
			GestionComentario negocio = new GestionComentario();
			
			//negocio.insertar(idcomentario, calificacion, descripcion, idsala);
			negocio.insertar(idcomentario, calificacion, descripcion, idsala);
			System.out.println("insertando..");
			
			RequestDispatcher rd = request.getRequestDispatcher("InsertarComentario.jsp");
			rd.forward(request, response);
			
			
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
	}

}
